from flask import Flask,render_template
import config
from exts import db,mail,cache
from models import UserModel
from blueprints.auth import bp as auth_bp
from blueprints.index import bp as index_bp
from blueprints.person import bp as person_bp
from blueprints.product import bp as product_bp
from blueprints.admin import bp as admin_bp
from flask_migrate import Migrate

app = Flask(__name__)
# 绑定配置文件
app.config.from_object(config)
app.config["SECRET_KEY"] = 'TPmi4aLWRbyVq8zu9v82dWYW1'
app.config['JSON_AS_ASCII']=False
app.config['CACHE_TYPE'] = 'simple'  # 使用 simple 缓存模式
app.config['CACHE_DEFAULT_TIMEOUT'] = 60  # 缓存默认过期时间（秒）

db.init_app(app)
mail.init_app(app)
cache.init_app(app)

migrate=Migrate(app,db)

app.register_blueprint(auth_bp)
app.register_blueprint(index_bp)
app.register_blueprint(person_bp)
app.register_blueprint(product_bp)
app.register_blueprint(admin_bp)

# 登录页面
@app.route('/')
def hello():
    return render_template("Login/login.html")

# @app.route('/cb')
# def cb():
#     return render_template("tets/Magnifier/index.html")

if __name__ == '__main__':
    app.run()
